const Omit = require("../template")

function testOmitAdvancedMethods() {
  console.log(
    "1. 对象排除高级方法 - 深度排除测试:",
    (() => {
      const object = { a: { b: { c: 1 } }, d: { e: { f: 2 } }, g: 3 }
      const result = Omit.omitDeep(object, 'a.b.c', 'd.e.f')
      const expected = { g: 3 }
      return JSON.stringify(result) === JSON.stringify(expected)
    })()
  )

  console.log(
    "2. 对象排除高级方法 - 条件排除测试:",
    (() => {
      const object = { a: 1, b: 2, c: 3, d: 4, e: 5 }
      const result = Omit.omitBy(object, (value, key) => value > 3)
      const expected = { a: 1, b: 2, c: 3 }
      return JSON.stringify(result) === JSON.stringify(expected)
    })()
  )

  console.log(
    "3. 对象排除高级方法 - 类型排除测试:",
    (() => {
      const object = { a: 1, b: '2', c: 3, d: '4', e: 5 }
      const result = Omit.omitByType(object, 'string')
      const expected = { a: 1, c: 3, e: 5 }
      return JSON.stringify(result) === JSON.stringify(expected)
    })()
  )

  console.log(
    "4. 对象排除高级方法 - 正则排除测试:",
    (() => {
      const object = { a1: 1, b2: 2, c3: 3, d4: 4, e5: 5 }
      const result = Omit.omitByPattern(object, /[0-9]/)
      return Object.keys(result).length === 0
    })()
  )

  console.log(
    "5. 对象排除高级方法 - 默认值排除测试:",
    (() => {
      const object = { a: 1, b: 2, c: 3, d: 4, e: 5 }
      const result = Omit.omitWithDefaults(object, 'a', 'c', { b: 0, d: 0 })
      const expected = { b: 0, d: 0, e: 5 }
      return JSON.stringify(result) === JSON.stringify(expected)
    })()
  )

  console.log(
    "6. 对象排除高级方法 - 转换排除测试:",
    (() => {
      const object = { a: 1, b: 2, c: 3, d: 4, e: 5 }
      const result = Omit.omitWithTransform(object, 'a', 'c', { b: x => x * 2, d: x => x * 3 })
      const expected = { b: 4, d: 12, e: 5 }
      return JSON.stringify(result) === JSON.stringify(expected)
    })()
  )

  console.log(
    "7. 对象排除高级方法 - 验证排除测试:",
    (() => {
      const object = { a: 1, b: 2, c: 3, d: 4, e: 5 }
      const result = Omit.omitWithValidation(object, 'a', 'c', { min: 1, max: 10 })
      const expected = { b: 2, d: 4, e: 5 }
      return JSON.stringify(result) === JSON.stringify(expected)
    })()
  )

  console.log(
    "8. 对象排除高级方法 - 空对象排除测试:",
    (() => {
      const object = {}
      const result = Omit.omit(object, 'a', 'b')
      return Object.keys(result).length === 0
    })()
  )

  console.log(
    "9. 对象排除高级方法 - 单属性对象排除测试:",
    (() => {
      const object = { a: 1 }
      const result = Omit.omit(object, 'a')
      return Object.keys(result).length === 0
    })()
  )

  console.log(
    "10. 对象排除高级方法 - 复杂对象排除测试:",
    (() => {
      const object = {
        user: { name: 'John', age: 30 },
        settings: { theme: 'dark', lang: 'en' },
        data: { value: 100 }
      }
      const result = Omit.omit(object, 'user', 'settings')
      const expected = { data: { value: 100 } }
      return JSON.stringify(result) === JSON.stringify(expected)
    })()
  )

  console.log(
    "11. 对象排除高级方法 - 嵌套属性排除测试:",
    (() => {
      const object = {
        user: { profile: { name: 'John', age: 30 } },
        settings: { theme: 'dark' }
      }
      const result = Omit.omitDeep(object, 'user.profile.name')
      const expected = {
        user: { profile: { age: 30 } },
        settings: { theme: 'dark' }
      }
      return JSON.stringify(result) === JSON.stringify(expected)
    })()
  )

  console.log(
    "12. 对象排除高级方法 - 混合类型排除测试:",
    (() => {
      const object = { a: 1, b: '2', c: true, d: null, e: undefined }
      const result = Omit.omitByType(object, 'string')
      const expected = { a: 1, c: true, d: null, e: undefined }
      return JSON.stringify(result) === JSON.stringify(expected)
    })()
  )

  console.log(
    "13. 对象排除高级方法 - 正则模式排除测试:",
    (() => {
      const object = { user_name: 'John', user_age: 30, data_value: 100 }
      const result = Omit.omitByPattern(object, /^user_/)
      const expected = { data_value: 100 }
      return JSON.stringify(result) === JSON.stringify(expected)
    })()
  )

  console.log(
    "14. 对象排除高级方法 - 条件组合排除测试:",
    (() => {
      const object = { a: 1, b: 2, c: 3, d: 4, e: 5 }
      const result = Omit.omitBy(object, (value, key) => value > 2 && key !== 'd')
      const expected = { a: 1, b: 2, d: 4 }
      return JSON.stringify(result) === JSON.stringify(expected)
    })()
  )

  console.log(
    "15. 对象排除高级方法 - 转换组合排除测试:",
    (() => {
      const object = { a: 1, b: 2, c: 3, d: 4, e: 5 }
      const result = Omit.omitWithTransform(object, 'a', 'c', {
        b: x => x * 2,
        d: x => x * 3,
        e: x => x * 4
      })
      const expected = { b: 4, d: 12, e: 20 }
      return JSON.stringify(result) === JSON.stringify(expected)
    })()
  )
}

testOmitAdvancedMethods()
